package com.iee.collection.list;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

/**
 * com.google.common.collect.Lists
 */
public class Listss {

    public static void main(String[] args) {
        // 集合初始化
        List<Integer> list = Lists.newArrayList();
        System.out.println(list);  // []
        List<Integer> list1 = Lists.newArrayList(1, 2, 3);
        System.out.println(list1); // [1, 2, 3]

        // 笛卡尔积
        List<Integer> list11 = Lists.newArrayList(1, 2, 3);
        List<Integer> list22 = Lists.newArrayList(4,5);
        List<List<Integer>> productList = Lists.cartesianProduct(list1,list22);
        System.out.println(productList); // [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]

        // 分页  将一个大集合拆分为小集合
        List<Integer> list33 = Lists.newArrayList(1, 2, 3, 4, 5);
        List<List<Integer>> partitionList = Lists.partition(list33, 2);
        System.out.println(partitionList);   // [[1, 2], [3, 4], [5]]

        // 流处理  如果我们想把某个集合转换成另外一个接口
        List<String> list44 = Lists.newArrayList("a","b","c");
        List<String> collect = list44.stream().map(x -> x.toLowerCase()).collect(Collectors.toList());
        System.out.println(collect);
        // 倒序
        List<Integer> reverseList = Lists.reverse(list1);
        System.out.println(reverseList);


    }

}
